'Clase para el Modulo del Login
Public Class clsLoginRN
  Private cLogin As New clsLoginSD

  Private nEmpleado, nTipoEmpleado As Integer
  Private cNombre As String

  Private nAutoDescuentoCob, nAutoCreditoCC, nAutoCargoCC, nAutoSFavorCC As Boolean
  Private nAutoValeCC, nAutoCheque, nAutoRetiroCC, nAutoCreditoCP, nAutoCargoCP As Boolean
  Private nAutoSFavorCP, nAutoImpFact, nAutoDescuento, nAutoChequeCC As Boolean

#Region "Lectura de Datos"
  Public Function cargaAlmacenRN() As Integer
    Dim dr As DataRow
    Dim dst As New DataSet

    Try
      dst = cLogin.LeeAlmacenSD()
      For Each dr In dst.Tables(0).Rows
        Return dr(0)
      Next
    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Critical)
      Return 1
    End Try

  End Function

  'Carga Empresa, edu 15 Jun 06
  Public Function cargaEmpresaRN() As Integer
    Dim dr As DataRow
    Dim dst As New DataSet

    Try
      dst = cLogin.LeeEmpresaSD()
      For Each dr In dst.Tables(0).Rows
        Return dr(0)
      Next
    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Critical)
      Return 1
    End Try

  End Function

  Public Function cargaDatos(Optional ByVal strEmlUsuario As String = "", _
                             Optional ByVal strPassword As String = "") As DataSet
    Dim dr As DataRow

    Try
      If strEmlUsuario = "admin" And strPassword = "admin" Then
        nEmpleado = 0
        cNombre = "Superusuario"
        nTipoEmpleado = 0

        nCofiguraParametros = True
      Else
        cargaDatos = cLogin.leeDatosEmpleado(strEmlUsuario, strPassword)

        If cargaDatos.Tables(0).Rows.Count > 0 Then
          dr = cargaDatos.Tables(0).Rows(0)

          nEmpleado = dr("Id")
          cNombre = dr("Nombre")
          nTipoEmpleado = dr("nIdTipoUsuario")

          nCofiguraParametros = dr("nParametros")
        Else
          nEmpleado = -1
          nCofiguraParametros = False
        End If
      End If

    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Critical)
    End Try

    Return Nothing
  End Function

  Public Sub leeBanderasPermisos(ByVal TipoEmpleado As Integer)
    Dim ds As DataSet
    Dim dr As DataRow

    Try
      ds = cLogin.leeBanderasPermisos(TipoEmpleado)

      If ds.Tables(0).Rows.Count > 0 Then
        dr = ds.Tables(0).Rows(0)
        nAutoDescuentoCob = dr("nAutoDescuentoCob")
        nAutoCreditoCC = dr("nAutoCreditoCC")
        nAutoCargoCC = dr("nAutoCargoCC")
        nAutoSFavorCC = dr("nAutoSFavorCC")
        nAutoValeCC = dr("nAutoValeCC")
        nAutoChequeCC = dr("nAutoChequeCC")
        nAutoRetiroCC = dr("nAutoRetiroCC")
        nAutoCreditoCP = dr("nAutoCreditoCP")
        nAutoCargoCP = dr("nAutoCargoCP")
        nAutoSFavorCP = dr("nAutoSFavorCP")
        nAutoImpFact = dr("nAutoImpFact")
        'nauto()
      End If

    Catch ex As Exception
      MsgBox(ex.Message, MsgBoxStyle.Critical)
    End Try
  End Sub
#End Region

#Region "Propiedades"
  Public Overridable Property IdEmpleado() As Integer
    Get
      Return nEmpleado
    End Get

    Set(ByVal Value As Integer)
      nEmpleado = Value
    End Set
  End Property

  Public Overridable Property Nombre() As String
    Get
      Return cNombre
    End Get

    Set(ByVal Value As String)
      cNombre = Value
    End Set
  End Property

  Public Overridable Property TipoEmpleado() As Integer
    Get
      Return nTipoEmpleado
    End Get

    Set(ByVal Value As Integer)
      nTipoEmpleado = Value
    End Set
  End Property

  Public ReadOnly Property ADescuentoCob() As Boolean
    Get
      Return nAutoDescuentoCob
    End Get
  End Property
  Public ReadOnly Property ACreditoCC() As Boolean
    Get
      Return nAutoCreditoCC
    End Get
  End Property
  Public ReadOnly Property ACargoCC() As Boolean
    Get
      Return nAutoCargoCC
    End Get
  End Property
  Public ReadOnly Property ASFavorCC() As Boolean
    Get
      Return nAutoSFavorCC
    End Get
  End Property
  Public ReadOnly Property nAValeCC() As Boolean
    Get
      Return nAutoValeCC
    End Get
  End Property
  Public ReadOnly Property AChequeCC() As Boolean
    Get
      Return nAutoChequeCC
    End Get
  End Property
  Public ReadOnly Property ARetiroCC() As Boolean
    Get
      Return nAutoRetiroCC
    End Get
  End Property
  Public ReadOnly Property ACreditoCP() As Boolean
    Get
      Return nAutoCreditoCP
    End Get
  End Property
  Public ReadOnly Property ACargoCP() As Boolean
    Get
      Return nAutoCargoCP
    End Get
  End Property
  Public ReadOnly Property ASFavorCP() As Boolean
    Get
      Return nAutoSFavorCP
    End Get
  End Property
  Public ReadOnly Property AImpFact() As Boolean
    Get
      Return nAutoImpFact
    End Get
  End Property
#End Region
End Class
